/** *******************************************************************
 * FlexDatabaseManager
 * Copyright (c) 2008 Jonnie Spratley. All Rights Reserved.
 * @author  Jonnie Spratley
 * @contact jonniespratley@gmail.com
 * @internal
 ******************************************************************* */
package com.jonniespratley.flexdatabasemanager.model
{
	import com.adobe.cairngorm.model.IModelLocator;
	import com.jonniespratley.flexdatabasemanager.utils.PagedCollection;
	import com.jonniespratley.flexdatabasemanager.view.assets.AssetManager;
	import com.jonniespratley.flexdatabasemanager.view.assets.SectionContent;
	import com.jonniespratley.flexdatabasemanager.vo.AnalyzeVO;
	import com.jonniespratley.flexdatabasemanager.vo.DatabaseVO;
	import com.jonniespratley.flexdatabasemanager.vo.FieldVO;
	import com.jonniespratley.flexdatabasemanager.vo.IndexVO;
	import com.jonniespratley.flexdatabasemanager.vo.ServerVO;
	import com.jonniespratley.flexdatabasemanager.vo.TableCheckVO;
	import com.jonniespratley.flexdatabasemanager.vo.TableStatusVO;
	import com.jonniespratley.flexdatabasemanager.vo.TableVO;
	import com.jonniespratley.flexdatabasemanager.vo.UserVO;
	
	import mx.collections.ArrayCollection;

	
    [Bindable]
	public final class ModelLocator implements IModelLocator
	{
		/**
		 * Defines the Singleton instance of the Application ModelLocator
		 */
		private static var instance:ModelLocator;

		public function ModelLocator()
		{
			if( instance != null ) throw new Error( "Error: Singletons can only be instantiated via getInstance() method!" );

			ModelLocator.instance = this;
		}

		/**
		 * Returns the Singleton instance of the Application ModelLocator
		 */
		public static function getInstance():ModelLocator
		{
			if( instance == null )	instance = new ModelLocator();

			return instance;
		}

		// *********** Public Variables that our views are going to bind to ************** \\
		
		/* Holds all of the icons and images */
		public var assets:AssetManager = new AssetManager();
		/* Holds all of the information for mysql, for the clients */
		public var content:SectionContent = new SectionContent();
		public var isConsoleVisible:Boolean = false;
		public var interactingWithServer:Boolean = false;
		public var globalStatusMessage:String;
		public var console:String;
		
		/* Help */
		public var helpCollection:ArrayCollection;
		public var helpSearchResultsCollection:ArrayCollection;
	
		/* Databases */
		public var databaseCollection:ArrayCollection;
		public var databasesSizeCollection:ArrayCollection;
		public var databasesAndTablesCollection:ArrayCollection;
		public var databasesArray:Array = new Array();
		
		/* Databases and Tables Collections */
		public var tableCollection:ArrayCollection;
		//public var tablesArray:Array = new Array();
		
		/* Tables and Fields Collections */
		public var tableAndFieldsCollection:ArrayCollection;
		public var tableCheck:TableCheckVO;
		
		/* Table Status Collections */
		public var tableStatusCollection:ArrayCollection;
		
		/* Tables Data Collections */
		public var tableDataPagedCollection:PagedCollection;
		public var tableDataCollection:ArrayCollection;
		public var tableDataArray:Array = new Array();
			
		/* Tables Fields Collections */
		public var tableColumnsCollection:ArrayCollection;
		public var tableColumnsArray:Array = new Array();
		public var tableIndexCollection:ArrayCollection;
		public var tableReferenceCollection:ArrayCollection;
		
		/* Query Collections */
		public var queryCollection:ArrayCollection;
		public var queryAnalyzedCollection:ArrayCollection;
		public var queryXMLCollection:XML;
		public var queryJSONCollection:String;
		public var queryAnalyzed:AnalyzeVO;
		public var queryExplainCollection:ArrayCollection;
		public var queryFavoritesCollection:ArrayCollection = new ArrayCollection();
		public var queryHistoryCollection:ArrayCollection = new ArrayCollection();
	
		/* Database Info Collections */
		public var databaseIndexCollection:ArrayCollection;
		public var databaseFunctionCollection:ArrayCollection;
		public var databaseProcedureCollection:ArrayCollection;
		public var databaseViewCollection:ArrayCollection;
		
		/* System Info Collections */
		public var systemVariablesCollection:ArrayCollection;
		public var systemProcessesCollection:ArrayCollection;
		public var systemStatusCollection:ArrayCollection;
		public var systemUsersCollection:ArrayCollection;
		public var systemCharsetsCollection:ArrayCollection;
		public var systemPrivilagesCollection:ArrayCollection;
		
		public var generalVariablesCollection:ArrayCollection;
		
		/* Dashboard Info Collections */
		public var mysqlInfoCollection:ArrayCollection;
		public var phpInfoCollection:ArrayCollection;
		public var serverInfoCollection:ArrayCollection;
		public var queryInfoCollection:ArrayCollection;
		public var trafficInfoCollection:ArrayCollection;
		public var serverInfo:ServerVO;
		
		/* MySQL Utility Collections */
		public var mysqlBytesCollection:ArrayCollection;
		public var mysqlConnectionsCollection:ArrayCollection;
		public var mysqlCommandsCollection:ArrayCollection;
		public var mysqlInnoDbCollection:ArrayCollection;
		public var mysqlKeysCollection:ArrayCollection;
		public var mysqlOpenCollection:ArrayCollection;
		public var mysqlPerformanceCollection:ArrayCollection;
		public var mysqlQcacheCollection:ArrayCollection;
		public var mysqlShowCommandsCollection:ArrayCollection;
		public var mysqlSortCollection:ArrayCollection;
		public var mysqlTempCollection:ArrayCollection;
		public var mysqlHandlersCollection:ArrayCollection;
		public var mysqlReplicationCollection:ArrayCollection;
		public var mysqlThreadsCollection:ArrayCollection;
		public var mysqlQuestionsCollection:ArrayCollection;
		public var mysqlUptimeCollection:ArrayCollection;
		public var mysqlTrafficCollection:ArrayCollection;
		public var mysqlPollingConnectionCollection:ArrayCollection = new ArrayCollection();
		public var mysqlPollingQueryCollection:ArrayCollection = new ArrayCollection();
		public var mysqlPollingTrafficCollection:ArrayCollection = new ArrayCollection();
		
		/* Database Backup Collections */
		public var databaseBackupCollection:ArrayCollection;
		
		/* Current User/Database/Table/Field  */
		public var currentUser:UserVO;
		public var selectedTable:TableVO;
		public var selectedDatabase:DatabaseVO;
		public var selectedField:FieldVO;
		public var selectedTableStatus:TableStatusVO;
		public var selectedTableIndexes:IndexVO;
		
		/* Manage Visible Items in View */
		public var isLoggedIn:Boolean = false;
		public var isDatabasesVisible:Boolean = false;
		public var isTablesVisible:Boolean = false;
		public var isTablesDataVisible:Boolean = false;
		
		/* Manage Current View States */
		public var workflowState:uint = 0;
		public static const MYSQL_LOGIN:uint = 0;
		public static const MYSQL_DASHBOARD:uint = 1;
		
		public var tableOrDatabaseWorkflowState:uint = 0;
		public static const DATABASE_VIEW:uint = 0;
		public static const TABLE_VIEW:uint = 1;
		
	}
}